package typeInfo;

import java.util.function.IntFunction;

/**
 * @version: 1.0
 * @Description: TODO
 * @author: zZmH
 * @date: 2020/12/05 17:15
 */


public class Test {

    public static <T extends Comparable>T[] minmaxf(T... a)

    {
        Object[] mm = new Object[2];
        return (T[]) mm; // compiles with warning
    }
    public static <T extends Comparable> T[] minmax(IntFunction<T[]> constr, T... a){
        T[] apply = constr.apply(2);
        for (int i = 0; i < apply.length; i++) {
            apply[i] = a[i];
        }

        return apply;
    }
    public static void main(String[] args) {
       /* String[] strings = minmaxf("a", "b", "c");
        for (String string : strings) {
            System.out.println(string);
        }*/
        String[] minmax = minmax(String[]::new, "a", "b", "c");
        for (String s : minmax) {
            System.out.println(s);
        }

    }

    static void min(Eat<? extends Animal> eat) {
        Animal sb = eat.getSb();
//        eat.setSb(new Animal());  error!
//        eat.setSb(new Tiger());   error!


    }

    static void max(Eat<? super Tiger> eat) {
        Object sb = eat.getSb();
        eat.setSb(new Tiger());

//        eat.setSb(new Animal());  error!
//        eat.setSb(new Object());  error!

    }

}

class Animal{

}

class Tiger extends Animal{

}
class Rabbit extends Animal{

}
class BlackTiger extends Tiger{

}

class Eat<T> {
    T sb;

    public Eat(T sb) {
        this.sb = sb;
    }

    public Eat() {

    }

    public T getSb() {
        return sb;
    }

    public void setSb(T sb) {
        this.sb = sb;
    }
}